< previous page page_457 next page >

Page 457
Usually, data-bound lists present the user with a familiar set of names. The user can pick from these names, and then the program uses the selection to locate a more computer-like ID or code represented by the familiar name selected by the user. The table created for this example contains just such information.
Set the BoundColumn property of the data-bound list control to point to the NameID column of the ValidNames data set. To do this, select the data-bound list control, and then press F4 to bring up the property window. Now locate the BoundColumn property and set it to NameID.
Add two more labels and text boxes to display the new properties. Do this by selecting the existing two labels and the two text controls all as a set. Then select Edit | Copy. This places the four selected controls on the Clipboard. Now select Edit | Paste from the Visual Basic 5 main menu. This places copies of the controls on your new form. Answer Yes to the prompts that ask if you want to create a control array. Set the caption properties of the two new labels to Bound Column: and Bound Text:. Use Figure 12.4 as a guide in laying out the new controls.
0457-01.jpg
Figure 12.4.
Adding new controls to the 
CH1301.VBP project.
Finally, modify the code in the cmdGetList_Click event to match the following code. This shows you the results of the new BoundColumn and BoundText properties:
Private Sub cmdGetList_Click()
    Text1(0) = DBList1.ListField
    Text2(0) = DBList1.TEXT
    Text1(1) = DBList1.BoundColumn
    Text2(1) = DBList1.BoundText
End Sub
Notice that you added the array references to the code to account for the new control arrays. Now save and run the project. When you select an item from the list and click the GetList button, you'll see the BoundColumn and BoundText properties displayed in the appropriate textboxes, as shown in Figure 12.5.

 
< previous page page_457 next page >

If you like this book, buy it!